// 
// Decompiled by Procyon v0.5.36
// 

package com.orange.boot.dev2.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import java.io.Serializable;
import org.springframework.web.bind.annotation.RequestParam;
import io.swagger.annotations.ApiParam;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.PostMapping;
import io.swagger.annotations.ApiOperation;
import com.orange.boot.utils.R;
import org.springframework.web.bind.annotation.RequestBody;
import com.orange.boot.dev2.entity.CitrusExpert;
import javax.annotation.Resource;
import com.orange.boot.dev2.service.CitrusExpertService;
import io.swagger.annotations.Api;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping({"/dev2/citrus_expert"})
@Api(
        tags = {"在线柑橘专家"}
)
public class CitrusExpertController {
    @Resource
    CitrusExpertService citrusExpertService;

    public CitrusExpertController() {
    }

    @ApiOperation("增添专家信息")
    @PostMapping({"/add"})
    public R addDiseaseInformation(@RequestBody CitrusExpert citrusExpert) {
        return this.citrusExpertService.save(citrusExpert) ? R.ok().message("添加成功") : R.error("添加失败,请稍后再试");
    }

    @ApiOperation("修改专家信息")
    @PutMapping({"/update"})
    public R updateDiseaseInformation(@RequestBody CitrusExpert citrusExpert) {
        return this.citrusExpertService.updateById(citrusExpert) ? R.ok().message("修改成功") : R.error("修改失败,请稍后再试");
    }

    @ApiOperation("根据id删除")
    @DeleteMapping({"/delete"})
    public R delete(@ApiParam("专家id") @RequestParam("id") Long id) {
        return this.citrusExpertService.removeById(id) ? R.ok().message("删除成功") : R.error("删除失败,请稍后再试");
    }

    @ApiOperation("根据id获取")
    @GetMapping({"/get"})
    public R get(@ApiParam("专家id") @RequestParam("id") Long id) {
        CitrusExpert byId = (CitrusExpert)this.citrusExpertService.getById(id);
        return byId != null ? R.ok().message("获取成功").data("result", byId) : R.error("获取失败,请稍后再试");
    }

    @ApiOperation("分页显示专家信息")
    @GetMapping({"/browse"})
    public R browse(@ApiParam("页面数") @RequestParam("page") Integer pageNum, @ApiParam("页面大小") @RequestParam("size") Integer pageSize) {
        Page<CitrusExpert> browse = (Page)this.citrusExpertService.page(new Page((long)pageNum, (long)pageSize));
        return R.ok().data("browse", browse);
    }
}
